<?php

use Fisharebest\Webtrees\Http\RequestHandlers\BroadcastPage;
use Fisharebest\Webtrees\Http\RequestHandlers\CleanDataFolder;
use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\Http\RequestHandlers\CreateTreePage;
use Fisharebest\Webtrees\Http\RequestHandlers\EmailPreferencesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees;
use Fisharebest\Webtrees\Http\RequestHandlers\MapDataList;
use Fisharebest\Webtrees\Http\RequestHandlers\MergeTreesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAllPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesAnalyticsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesBlocksPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesChartsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesDataFixesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesFootersPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesHistoricEventsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesLanguagesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesListsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesMenusPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesReportsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesSidebarsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesTabsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\ModulesThemesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\PendingChanges;
use Fisharebest\Webtrees\Http\RequestHandlers\PhpInformation;
use Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsPage;
use Fisharebest\Webtrees\Http\RequestHandlers\SitePreferencesPage;
use Fisharebest\Webtrees\Http\RequestHandlers\SiteRegistrationPage;
use Fisharebest\Webtrees\Http\RequestHandlers\TreePageDefaultEdit;
use Fisharebest\Webtrees\Http\RequestHandlers\UserPageDefaultEdit;
use Fisharebest\Webtrees\Http\RequestHandlers\UsersCleanupPage;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\FamilyListModule;
use Fisharebest\Webtrees\Module\IndividualListModule;
use Fisharebest\Webtrees\Module\MediaListModule;
use Fisharebest\Webtrees\Module\ModuleAnalyticsInterface;
use Fisharebest\Webtrees\Module\ModuleBlockInterface;
use Fisharebest\Webtrees\Module\ModuleChartInterface;
use Fisharebest\Webtrees\Module\ModuleConfigInterface;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleDataFixInterface;
use Fisharebest\Webtrees\Module\ModuleFooterInterface;
use Fisharebest\Webtrees\Module\ModuleHistoricEventsInterface;
use Fisharebest\Webtrees\Module\ModuleInterface;
use Fisharebest\Webtrees\Module\ModuleLanguageInterface;
use Fisharebest\Webtrees\Module\ModuleListInterface;
use Fisharebest\Webtrees\Module\ModuleMenuInterface;
use Fisharebest\Webtrees\Module\ModuleReportInterface;
use Fisharebest\Webtrees\Module\ModuleSidebarInterface;
use Fisharebest\Webtrees\Module\ModuleTabInterface;
use Fisharebest\Webtrees\Module\ModuleThemeInterface;
use Fisharebest\Webtrees\Module\NoteListModule;
use Fisharebest\Webtrees\Module\RepositoryListModule;
use Fisharebest\Webtrees\Module\SourceListModule;
use Fisharebest\Webtrees\Module\SubmitterListModule;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\User;
use Fisharebest\Webtrees\Webtrees;
use Illuminate\Support\Collection;

/**
 * @var Collection<User>                          $administrators
 * @var Collection<ModuleInterface>               $all_modules_disabled
 * @var Collection<ModuleInterface>               $all_modules_enabled
 * @var Collection<Tree>                          $all_trees
 * @var Collection<User>                          $all_users
 * @var Collection<ModuleAnalyticsInterface>      $analytics_modules_disabled
 * @var Collection<ModuleAnalyticsInterface>      $analytics_modules_enabled
 * @var Collection<ModuleBlockInterface>          $block_modules_disabled
 * @var Collection<ModuleBlockInterface>          $block_modules_enabled
 * @var array<string,int>                         $changes
 * @var Collection<ModuleChartInterface>          $chart_modules_disabled
 * @var Collection<ModuleChartInterface>          $chart_modules_enabled
 * @var Collection<ModuleCustomInterface>         $custom_updates
 * @var Collection<ModuleDataFixInterface>        $data_fix_modules_disabled
 * @var Collection<ModuleDataFixInterface>        $data_fix_modules_enabled
 * @var Collection<string,int>                    $families
 * @var FamilyListModule|null                     $family_list_module
 * @var Collection<ModuleFooterInterface>         $footer_modules_disabled
 * @var Collection<ModuleFooterInterface>         $footer_modules_enabled
 * @var Collection<ModuleHistoricEventsInterface> $history_modules_disabled
 * @var Collection<ModuleHistoricEventsInterface> $history_modules_enabled
 * @var Collection<string,int>                    $individuals
 * @var IndividualListModule|null                 $individual_list_module
 * @var Collection<ModuleLanguageInterface>       $language_modules_disabled
 * @var Collection<ModuleLanguageInterface>       $language_modules_enabled
 * @var string                                    $latest_version
 * @var Collection<ModuleListInterface>           $list_modules_disabled
 * @var Collection<ModuleListInterface>           $list_modules_enabled
 * @var Collection<User>                          $managers
 * @var Collection<string,int>                    $media
 * @var MediaListModule|null                      $media_list_module
 * @var Collection<ModuleMenuInterface>           $menu_modules_disabled
 * @var Collection<ModuleMenuInterface>           $menu_modules_enabled
 * @var Collection<User>                          $moderators
 * @var Collection<string,int>                    $notes
 * @var NoteListModule|null                       $note_list_module
 * @var Collection<ModuleInterface>               $other_modules
 * @var Collection<ModuleReportInterface>         $report_modules_disabled
 * @var Collection<ModuleReportInterface>         $report_modules_enabled
 * @var Collection<string,int>                    $repositories
 * @var RepositoryListModule|null                 $repository_list_module
 * @var Collection<string>                        $server_errors
 * @var Collection<string>                        $server_warnings
 * @var bool                                      $show_synchronize
 * @var Collection<ModuleSidebarInterface>        $sidebar_modules_disabled
 * @var Collection<ModuleSidebarInterface>        $sidebar_modules_enabled
 * @var Collection<string,int>                    $sources
 * @var SourceListModule|null                     $source_list_module
 * @var Collection<string,int>                    $submitters
 * @var SubmitterListModule|null                  $submitter_list_module
 * @var Collection<ModuleTabInterface>            $tab_modules_disabled
 * @var Collection<ModuleTabInterface>            $tab_modules_enabled
 * @var Collection<ModuleThemeInterface>          $theme_modules_disabled
 * @var Collection<ModuleThemeInterface>          $theme_modules_enabled
 * @var string                                    $title
 * @var Collection<User>                          $unapproved
 * @var Collection<User>                          $unverified
 */

?>

<h1><?= $title ?></h1>

<!-- WEBSITE / WEBTREES -->
<div class="card mb-4">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Website') ?>
            <span class="badge badge-secondary" dir="ltr">
                <?= e(Webtrees::VERSION) ?>
            </span>
        </h2>
    </div>
    <div class="card-body">
        <?php foreach ($server_errors as $server_error) : ?>
            <p class="alert alert-danger"><?= $server_error ?></p>
        <?php endforeach ?>

        <?php foreach ($server_warnings as $server_warning) : ?>
            <p class="alert alert-warning"><?= $server_warning ?></p>
        <?php endforeach ?>

        <p class="card-text">
            <?= /* I18N: %s is a URL/link to the project website */
            I18N::translate('Support and documentation can be found at %s.', '<a href="https://webtrees.net/">webtrees.net</a>') ?>
        </p>
        <p class="card-text">
            <?php if ($latest_version === '') : ?>
                <?= I18N::translate('No upgrade information is available.') ?>
            <?php elseif (version_compare(Webtrees::VERSION, $latest_version) < 0) : ?>
                <div class="alert alert-info">
                    <?= I18N::translate('A new version of webtrees is available.') ?>
                    <a href="<?= e(route('upgrade')) ?>" class="alert-link">
                        <?= /* I18N: %s is a version number */
                        I18N::translate('Upgrade to webtrees %s.', e($latest_version)) ?>
                    </a>
                </div>
            <?php else : ?>
                <?= I18N::translate('This is the latest version of webtrees. No upgrade is available.') ?>
            <?php endif ?>
        </p>

        <?php foreach ($custom_updates as $module) : ?>
        <div class="alert alert-info">
            <?= view('icons/information') ?>
            <?= I18N::translate('An upgrade is available.') ?>
            <br>
            <?= $module->title() ?> — <?= e($module->customModuleVersion()) ?> — <?= e($module->customModuleLatestVersion()) ?>
        </div>
        <?php endforeach ?>

        <div class="row">
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/preferences') ?></span>
                        <a href="<?= e(route(SitePreferencesPage::class)) ?>">
                            <?= I18N::translate('Website preferences') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/email') ?></span>
                        <a href="<?= e(route(EmailPreferencesPage::class)) ?>">
                            <?= I18N::translate('Sending email') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/user') ?></span>
                        <a href="<?= e(route(SiteRegistrationPage::class)) ?>">
                            <?= I18N::translate('Sign-in and registration') ?>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/list') ?></span>
                        <a href="<?= e(route(SiteLogsPage::class)) ?>">
                            <?= I18N::translate('Website logs') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/delete') ?></span>
                        <a href="<?= e(route(CleanDataFolder::class)) ?>">
                            <?= I18N::translate('Clean up data folder') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/help') ?></span>
                        <a href="<?= e(route(PhpInformation::class)) ?>">
                            <?= I18N::translate('Server information') ?>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<!-- FAMILY TREES -->
<div class="card mb-4 <?= array_sum($changes) ? 'card-outline-danger' : '' ?>">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Family trees') ?>
            <span class="badge badge-secondary">
                    <?= I18N::number($all_trees->count()) ?>
                </span>
        </h2>
    </div>

    <div class="card-body">
        <?php if ($all_trees->isEmpty()) : ?>
            <p class="alert alert-info">
                <?= I18N::translate('You need to create a family tree.') ?>
            </p>
        <?php endif ?>

        <ul class="fa-ul">
            <li>
                <span class="fa-li"><?= view('icons/add') ?></span>
                <a href="<?= e(route(CreateTreePage::class)) ?>">
                    <?= I18N::translate('Create a family tree') ?>
                </a>
            </li>
            <li>
                <span class="fa-li"><?= view('icons/block') ?></span>
                <a href="<?= e(route(TreePageDefaultEdit::class)) ?>">
                    <?= I18N::translate('Set the default blocks for new family trees') ?>
                </a>
            </li>
            <?php if (count($all_trees) > 1) : ?>
                <li>
                    <span class="fa-li"><?= view('icons/merge') ?></span>
                    <a href="<?= e(route(MergeTreesPage::class)) ?>">
                        <?= I18N::translate('Merge family trees') ?>
                    </a>
                </li>
            <?php endif ?>
        </ul>

        <table class="table table-sm">
            <caption class="sr-only">
                <?= I18N::translate('Family trees') ?>
            </caption>

            <thead>
                <tr>
                    <th><?= I18N::translate('Family tree') ?></th>
                    <th class="align-digits"><?= I18N::translate('Pending changes') ?></th>
                    <th class="d-none d-sm-table-cell align-digits"><?= I18N::translate('Individuals') ?></th>
                    <th class="d-none d-lg-table-cell align-digits"><?= I18N::translate('Families') ?></th>
                    <th class="d-none d-sm-table-cell align-digits"><?= I18N::translate('Sources') ?></th>
                    <th class="d-none d-lg-table-cell align-digits"><?= I18N::translate('Repositories') ?></th>
                    <th class="d-none d-sm-table-cell align-digits"><?= I18N::translate('Media') ?></th>
                    <th class="d-none d-lg-table-cell align-digits"><?= I18N::translate('Notes') ?></th>
                    <th class="d-none d-lg-table-cell align-digits"><?= I18N::translate('Submitters') ?></th>
                </tr>
            </thead>

            <tbody>
                <?php foreach ($all_trees as $tree) : ?>
                    <tr class="<?= $changes[$tree->id()] ? 'danger' : '' ?>">
                        <th scope="row">
                            <?= view('icons/preferences') ?>
                            <a href="<?= e(route(ManageTrees::class, ['tree' => $tree->name()])) ?>">
                                <?= e($tree->name()) ?>
                                -
                                <?= e($tree->title()) ?>
                            </a>
                        </th>
                        <td style="text-align: right;">
                            <?php if ($changes[$tree->id()]) : ?>
                                <a href="<?= e(route(PendingChanges::class, ['tree' => $tree->name(), 'url' => route(ControlPanel::class)])) ?>">
                                    <?= I18N::number($changes[$tree->id()]) ?>
                                    <span class="sr-only"><?= I18N::translate('Pending changes') ?> <?= e($tree->title()) ?></span>
                                </a>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-sm-table-cell align-digits">
                            <?php if ($individuals[$tree->id()] > 0) : ?>
                                <?php if ($individual_list_module instanceof IndividualListModule) : ?>
                                    <a href="<?= e($individual_list_module->listUrl($tree)) ?>"><?= I18N::number($individuals[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($individuals[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-lg-table-cell align-digits">
                            <?php if ($families[$tree->id()] > 0) : ?>
                                <?php if ($family_list_module instanceof FamilyListModule) : ?>
                                    <a href="<?= e($family_list_module->listUrl($tree)) ?>"><?= I18N::number($families[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($families[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-sm-table-cell align-digits">
                            <?php if ($sources[$tree->id()] > 0) : ?>
                                <?php if ($source_list_module instanceof SourceListModule) : ?>
                                    <a href="<?= e($source_list_module->listUrl($tree)) ?>"><?= I18N::number($sources[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($sources[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-lg-table-cell align-digits">
                            <?php if ($repositories[$tree->id()] > 0) : ?>
                                <?php if ($repository_list_module instanceof RepositoryListModule) : ?>
                                    <a href="<?= e($repository_list_module->listUrl($tree)) ?>"><?= I18N::number($repositories[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($repositories[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-sm-table-cell align-digits">
                            <?php if ($media[$tree->id()] > 0) : ?>
                                <?php if ($media_list_module instanceof MediaListModule) : ?>
                                    <a href="<?= e($media_list_module->listUrl($tree)) ?>"><?= I18N::number($media[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($media[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                        <td class="d-none d-lg-table-cell align-digits">
                            <?php if ($notes[$tree->id()] > 0) : ?>
                                <?php if ($note_list_module instanceof NoteListModule) : ?>
                                    <a href="<?= e($note_list_module->listUrl($tree)) ?>"><?= I18N::number($notes[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($notes[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                         <td class="d-none d-lg-table-cell align-digits">
                            <?php if ($submitters[$tree->id()] > 0) : ?>
                                <?php if ($submitter_list_module instanceof SubmitterListModule) : ?>
                                    <a href="<?= e($submitter_list_module->listUrl($tree)) ?>"><?= I18N::number($submitters[$tree->id()]) ?></a>
                                <?php else : ?>
                                    <?= I18N::number($submitters[$tree->id()]) ?>
                                <?php endif ?>
                            <?php else : ?>
                                -
                            <?php endif ?>
                        </td>
                    </tr>
                <?php endforeach ?>
            </tbody>

            <tfoot>
                <tr>
                    <th scope="row">
                        <?= I18N::translate('Total') ?>
                    </th>
                    <td class="align-digits">
                        <?= I18N::number(array_sum($changes)) ?>
                    </td>
                    <td class="d-none d-sm-table-cell align-digits">
                        <?= I18N::number($individuals->sum()) ?>
                    </td>
                    <td class="d-none d-lg-table-cell align-digits">
                        <?= I18N::number($families->sum()) ?>
                    </td>
                    <td class="d-none d-sm-table-cell align-digits">
                        <?= I18N::number($sources->sum()) ?>
                    </td>
                    <td class="d-none d-lg-table-cell align-digits">
                        <?= I18N::number($repositories->sum()) ?>
                    </td>
                    <td class="d-none d-sm-table-cell align-digits">
                        <?= I18N::number($media->sum()) ?>
                    </td>
                    <td class="d-none d-lg-table-cell align-digits">
                        <?= I18N::number($notes->sum()) ?>
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>

<?php if ($show_synchronize): ?>
    <?= view('admin/synchronize-trees') ?>
<?php endif ?>

<!-- USERS -->
<div class="card mb-4 <?= $unapproved || $unverified ? 'card-outline-danger' : '' ?>">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Users') ?>
            <span class="badge badge-secondary">
                    <?= I18N::number(count($all_users)) ?>
                </span>
        </h2>
    </div>
    <div class="card-body">
        <dl class="row">
            <?php foreach ([I18N::translate('Administrators') => $administrators, I18N::translate('Managers') => $managers, I18N::translate('Moderators') => $moderators, I18N::translate('Not verified by the user') => $unverified, I18N::translate('Not approved by an administrator') => $unapproved] as $label => $list) : ?>
                <?php if (!empty($list)) : ?>
                    <dt class="col-sm-6">
                        <?= $label ?>
                    </dt>
                    <dd class="col-sm-6">
                        <?php foreach ($list as $n => $user) : ?>
                            <?= $n ? I18N::$list_separator : '' ?>
                            <a href="<?= e(route('admin-users-edit', ['user_id' => $user->id()])) ?>" dir="auto">
                                <?= e($user->realName()) ?>
                            </a>
                        <?php endforeach ?>
                        <?php if ($list->isEmpty()) : ?>
                        —
                        <?php endif ?>
                    </dd>
                <?php endif ?>
            <?php endforeach ?>
        </dl>

        <div class="row">
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/preferences') ?></span>
                        <a href="<?= e(route('admin-users')) ?>">
                            <?= I18N::translate('User administration') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/add') ?></span>
                        <a href="<?= e(route('admin-users-create')) ?>">
                            <?= I18N::translate('Add a user') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/delete') ?></span>
                        <a href="<?= e(route(UsersCleanupPage::class)) ?>">
                            <?= I18N::translate('Delete inactive users') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/block') ?></span>
                        <a href="<?= e(route(UserPageDefaultEdit::class)) ?>">
                            <?= I18N::translate('Set the default blocks for new users') ?>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/email') ?></span>
                        <a href="<?= e(route(BroadcastPage::class, ['to' => 'all'])) ?>">
                            <?= I18N::translate('Send a message to all users') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/email') ?></span>
                        <a href="<?= e(route(BroadcastPage::class, ['to' => 'never_logged'])) ?>">
                            <?= I18N::translate('Send a message to users who have never signed in') ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/email') ?></span>
                        <a href="<?= e(route(BroadcastPage::class, ['to' => 'last_6mo'])) ?>">
                            <?= I18N::translate('Send a message to users who have not signed in for 6 months') ?>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<!-- MODULES -->
<div class="card mb-4">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Modules') ?>
            <?= view('components/badge', ['count' => $all_modules_enabled->count(), 'total' => $all_modules_disabled->count(), 'context' => 'secondary']) ?>
        </h2>
    </div>

    <div class="card-body">
        <ul class="fa-ul">
            <li>
                <span class="fa-li"><?= view('icons/module') ?></span>
                <a href="<?= e(route(ModulesAllPage::class)) ?>">
                    <?= I18N::translate('All modules') ?>
                </a>
                <?= view('components/badge', ['count' => $all_modules_enabled->count(), 'total' => $all_modules_disabled->count(), 'context' => 'primary']) ?>
            </li>
        </ul>

        <div class="row">
            <div class="col-sm-4">
                <h3>
                    <?= I18N::translate('Genealogy') ?>
                </h3>

                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/menu') ?></span>
                        <a href="<?= e(route(ModulesMenusPage::class)) ?>">
                            <?= I18N::translate('Menus') ?>
                        </a>
                        <?= view('components/badge', ['count' => $menu_modules_enabled->count(), 'total' => $menu_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/chart') ?></span>
                        <a href="<?= e(route(ModulesChartsPage::class)) ?>">
                            <?= I18N::translate('Charts') ?>
                        </a>
                        <?= view('components/badge', ['count' => $chart_modules_enabled->count(), 'total' => $chart_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/list') ?></span>
                        <a href="<?= e(route(ModulesListsPage::class)) ?>">
                            <?= I18N::translate('Lists') ?>
                        </a>
                        <?= view('components/badge', ['count' => $list_modules_enabled->count(), 'total' => $list_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/report') ?></span>
                        <a href="<?= e(route(ModulesReportsPage::class)) ?>">
                            <?= I18N::translate('Reports') ?>
                        </a>
                        <?= view('components/badge', ['count' => $report_modules_enabled->count(), 'total' => $report_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/data-fix') ?></span>
                        <a href="<?= e(route(ModulesDataFixesPage::class)) ?>">
                            <?= I18N::translate('Data fixes') ?>
                        </a>
                        <?= view('components/badge', ['count' => $data_fix_modules_enabled->count(), 'total' => $data_fix_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                </ul>

                <h3>
                    <?= I18N::translate('Website') ?>
                </h3>

                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/footer') ?></span>
                        <a href="<?= e(route(ModulesFootersPage::class)) ?>">
                            <?= I18N::translate('Footers') ?>
                        </a>
                        <?= view('components/badge', ['count' => $footer_modules_enabled->count(), 'total' => $footer_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/analytics') ?></span>
                        <a href="<?= e(route(ModulesAnalyticsPage::class)) ?>">
                            <?= I18N::translate('Tracking and analytics') ?>
                        </a>
                        <?= view('components/badge', ['count' => $analytics_modules_enabled->count(), 'total' => $analytics_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/theme') ?></span>
                        <a href="<?= e(route(ModulesThemesPage::class)) ?>">
                            <?= I18N::translate('Themes') ?>
                        </a>
                        <?= view('components/badge', ['count' => $theme_modules_enabled->count(), 'total' => $theme_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/language') ?></span>
                        <a href="<?= e(route(ModulesLanguagesPage::class)) ?>">
                            <?= I18N::translate('Languages') ?>
                        </a>
                        <?= view('components/badge', ['count' => $language_modules_enabled->count(), 'total' => $language_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                </ul>

            </div>

            <div class="col-sm-4">

                <h3>
                    <?= I18N::translate('Home page') ?>
                </h3>

                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/block') ?></span>
                        <a href="<?= e(route(ModulesBlocksPage::class)) ?>">
                            <?= I18N::translate('Blocks') ?>
                        </a>
                        <?= view('components/badge', ['count' => $block_modules_enabled->count(), 'total' => $block_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                </ul>

                <h3>
                    <?= I18N::translate('Individual page') ?>
                </h3>

                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/tab') ?></span>
                        <a href="<?= e(route(ModulesTabsPage::class)) ?>">
                            <?= I18N::translate('Tabs') ?>
                            <?= view('components/badge', ['count' => $tab_modules_enabled->count(), 'total' => $tab_modules_disabled->count(), 'context' => 'primary']) ?>
                        </a>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/sidebar') ?></span>
                        <a href="<?= e(route(ModulesSidebarsPage::class)) ?>">
                            <?= I18N::translate('Sidebars') ?>
                        </a>
                        <?= view('components/badge', ['count' => $sidebar_modules_enabled->count(), 'total' => $sidebar_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                    <li>
                        <span class="fa-li"><?= view('icons/history') ?></span>
                        <a href="<?= e(route(ModulesHistoricEventsPage::class)) ?>">
                            <?= I18N::translate('Historic events') ?>
                        </a>
                        <?= view('components/badge', ['count' => $history_modules_enabled->count(), 'total' => $history_modules_disabled->count(), 'context' => 'primary']) ?>
                    </li>
                </ul>

            </div>

            <div class="col-sm-4">

                <h3>
                    <?= I18N::translate('Other') ?>
                </h3>

                <ul class="fa-ul">
                    <?php foreach ($other_modules as $module) : ?>
                        <li>
                            <span class="fa-li"><?= view('icons/module') ?></span>

                            <?php if ($module->isEnabled()) : ?>
                                <?php if ($module instanceof ModuleConfigInterface) : ?>
                                    <a href="<?= e($module->getConfigLink()) ?>">
                                    <?= $module->title() ?>
                                    <?= view('icons/preferences') ?>
                                    </a>
                                <?php else : ?>
                                    <?= $module->title() ?>
                                <?php endif ?>
                            <?php else : ?>
                                <span class="text-muted">
                                    <span class="fa-li"><?= view('icons/module') ?></span>
                                     <?= $module->title() ?>
                                    <?php if ($module instanceof ModuleConfigInterface) : ?>
                                        <?= view('icons/preferences') ?>
                                    <?php endif ?>
                                    </span>
                                </span>
                            <?php endif ?>

                            <?php if ($module instanceof ModuleCustomInterface) : ?>
                                <?= view('admin/custom-module-info', ['module' => $module]) ?>
                            <?php endif ?>
                        </li>
                    <?php endforeach ?>
                </ul>
            </div>
        </div>
    </div>
</div>

<!-- MEDIA -->
<div class="card mb-4">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Media') ?>
        </h2>
    </div>
    <div class="card-body">
        <ul class="fa-ul">
            <li>
                <span class="fa-li"><?= view('icons/preferences') ?></span>
                <a href="<?= e(route('admin-media')) ?>">
                    <?= I18N::translate('Manage media') ?>
                </a>
            </li>
            <li>
                <span class="fa-li"><?= view('icons/upload') ?></span>
                <a href="<?= e(route('admin-media-upload')) ?>">
                    <?= I18N::translate('Upload media files') ?>
                </a>
            </li>
            <li>
                <span class="fa-li"><?= view('icons/link') ?></span>
                <a href="<?= e(route('admin-fix-level-0-media')) ?>">
                    <?= I18N::translate('Link media objects to facts and events') ?>
                </a>
            </li>
            <li>
                <span class="fa-li"><?= view('icons/upload') ?></span>
                <a href="<?= e(route('admin-webtrees1-thumbs')) ?>">
                    <?= I18N::translate('Import custom thumbnails from webtrees version 1') ?>
                </a>
            </li>
        </ul>
    </div>
</div>

<!-- MAPS -->
<div class="card mb-4">
    <div class="card-header">
        <h2 class="mb-0">
            <?= I18N::translate('Map') ?>
        </h2>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/location') ?></span>
                        <a href="<?= e(route(MapDataList::class)) ?>">
                            <?= I18N::translate('Geographic data') ?>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="col-sm-6">
                <ul class="fa-ul">
                    <li>
                        <span class="fa-li"><?= view('icons/map') ?></span>
                        <a href="<?= e(route('map-provider')) ?>">
                            <?= I18N::translate('Map provider') ?>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<!-- OLD FILES -->
<?php if (!empty($files_to_delete)) : ?>
    <div class="card mb-4 card-outline-danger">
        <div class="card-header">
            <h2 class="mb-0">
                <?= I18N::translate('Old files found') ?>
            </h2>
        </div>
        <div class="card-body">
            <p>
                <?= I18N::translate('Files have been found from a previous version of webtrees. Old files can sometimes be a security risk. You should delete them.') ?>
            </p>
            <ul class="list-unstyled">
                <?php foreach ($files_to_delete as $file_to_delete) : ?>
                    <li dir="ltr">
                        <code><?= e($file_to_delete) ?></code>
                    </li>
                <?php endforeach ?>
            </ul>
        </div>
    </div>
<?php endif ?>
